<%-- 
    Document   : ExaminationEditor
    Created on : 14-dic-2011, 14.33.50
    Author     : guybrush
--%>

<%@page import="javax.faces.context.FacesContext"%>
<%@page import="beans.util.ExtendedDataTableBean"%>
<%@ page pageEncoding="UTF-8" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>

<% ExtendedDataTableBean med = ((ExtendedDataTableBean) session.getAttribute("extendedDataTableBean")); 
   med.setContextPdfPat(((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getRealPath("/resources/pdf")); %>

<a4j:form id="examEdit">
    <rich:panel header="#{msg.examination} - ID: #{extendedDataTableBean.singleSelectedExam.id}"
                id="info_exam" style="width: 250px">
        <h:panelGrid columns="2" columnClasses="cl1, cl2">
            <h:outputText value="#{msg.type}: "/>
            <rich:inplaceSelect defaultLabel="#{msg.charters_slide}" value="#{extendedDataTableBean.singleSelectedExam.tipo}" 
                                showControls="false" >
                    <f:selectItem itemValue="1" itemLabel="#{msg.prog_exam}" />
                    <f:selectItem itemValue="2" itemLabel="#{msg.vaccination}" />
                    <f:selectItem itemValue="3" itemLabel="#{msg.voluntary}" />
            </rich:inplaceSelect>
            <h:outputText value="#{msg.expirationDate}: "/>
            <h:column>
                <h:outputText value="#{extendedDataTableBean.singleSelectedExam.scadenza}">
                    <f:convertDateTime type="date" dateStyle="long" />
                </h:outputText>
                <rich:spacer height="0px" width="3px" />
                <rich:calendar value="#{extendedDataTableBean.singleSelectedExam.scadenza}" popup="true"
                               showInput="false" showApplyButton="true"
                               direction="bottom-left" jointPoint="bottom-left" />
            </h:column>    
            <h:outputText value="#{msg.expirationType}: "/>
            <rich:inplaceSelect defaultLabel="#{msg.charters_slide}"
                                value="#{extendedDataTableBean.singleSelectedExam.tipo_scadenza}" >
                <f:selectItem itemValue="1" itemLabel="#{msg.periodic}" />
                <f:selectItem itemValue="2" itemLabel="#{msg.prog_med}" />
                <f:selectItem itemValue="3" itemLabel="#{msg.prog_bd}" />
            </rich:inplaceSelect>
            <h:outputText value="#{msg.performed}: "/>
            <h:selectBooleanCheckbox id="performed" value="#{extendedDataTableBean.singleSelectedExam.effettuata}" />
            <rich:spacer width="100%" height="5px"/>
            <f:facet name="footer">
                <h:panelGroup>
                    <h:outputText value="#{msg.description}: "/>
                    <rich:editor id="editor_descrizione" value="#{extendedDataTableBean.singleSelectedExam.realDescrizione}"
                                 width="220" height="30" theme="simple" >
                        <f:param name="force_p_newlines " value="false"/>
                        <f:param name="forced_root_block " value=""/>
                    </rich:editor>
                </h:panelGroup>
            </f:facet>
        </h:panelGrid>
        <h:panelGrid columns="3" columnClasses="b1, b2, b3" width="100%">
            <a4j:commandButton value="#{msg.update}" reRender="tableE, examEdit, patients_waiting_exam" disabled="#{extendedDataTableBean.updateDeleteButtonDisable}"
                               action="#{extendedDataTableBean.updateExamination()}" />

            <a4j:commandButton value="#{msg.new_}" reRender="tableE, examEdit" disabled="#{extendedDataTableBean.newButtonDisable}"
                               action="#{extendedDataTableBean.newExamination()}" />

            <a4j:commandButton value="#{msg.delete}" reRender="tableE, examEdit, patients_waiting_exam" disabled="#{extendedDataTableBean.updateDeleteButtonDisable}"
                               action="#{extendedDataTableBean.deleteExamination()}" />
        </h:panelGrid>
    </rich:panel>
</a4j:form>